package jp.co.hcs.attendancemanagement.inputdailyattendance.actionform;

import java.util.ArrayList;
import java.util.List;

import jp.co.hcs.attendancemanagement.inputdailyattendance.logic.dto.DailyWorkingActualResultDTO;
import jp.co.hcs.attendancemanagement.inputdailyattendance.logic.dto.EmployeeCompanyDTO;
import jp.co.hcs.attendancemanagement.inputdailyattendance.logic.dto.ProjectInfoDTO;
import jp.co.hcs.attendancemanagement.inputdailyattendance.logic.dto.RestTimeDTO;
import jp.co.hcs.attendancemanagement.inputdailyattendance.logic.dto.StampActualResultDTO;
import jp.co.hcs.attendancemanagement.util.StringUtil;

import org.apache.struts.action.ActionForm;
import org.apache.struts.util.LabelValueBean;

/**
 * The Class InputDailyAttendanceForm.
 */
public class InputDailyAttendanceForm extends ActionForm {

  /** The is editable. */
  private boolean isEditable = false;

  /** The day. */
  private String day;

  /** The month. */
  private String month;

  /** The year. */
  private String year;

  /** The day of week. */
  private String dayOfWeek;

  /** The user id. */
  private String userId;

  /** The init dto. */
  private EmployeeCompanyDTO initDTO = new EmployeeCompanyDTO();

  /** The time dto. */
  private DailyWorkingActualResultDTO timeDTO = new DailyWorkingActualResultDTO();

  /** The project info dto list. */
  private List<ProjectInfoDTO> projectInfoDTOList = new ArrayList<ProjectInfoDTO>();

  /** The attendance setting list. */
  private List<LabelValueBean> attendanceSettingList;

  /** The time setting list. */
  private List<LabelValueBean> timeSettingList;

  /** The stamp actual result dto. */
  private StampActualResultDTO stampActualResultDTO = new StampActualResultDTO();

  /** The rest time info dto list. */
  private List<RestTimeDTO> restTimeInfoDTOList;

  /** The substitute holiday. */
  private String substituteHoliday;

  /** The over time working per month. */
  private String overTimeWorkingPerMonth;

  /** The working time id. */
  private String workingTimeId;

  /** The total operation time. */
  private String totalOperationTime;
  
  private String leaveTime;

  /** The working time check exclusion flag. */
  private boolean workingTimeCheckExclusionFlag;

  /** The find rest detail flag. */
  private boolean findRestDetailFlag;

  /** The announcement. */
  private String announcement;

  /** The save success. */
  private boolean saveSuccess;

  /** The delete success. */
  private boolean deleteSuccess;

  /** The confirm success. */
  private boolean confirmSuccess;
  
  private boolean dateChangeFlag;

  /**
   * Reset data.
   */
  public void resetData() {
    isEditable = false;
    day = null;
    month = null;
    year = null;
    dayOfWeek = null;
    userId = null;
    initDTO = new EmployeeCompanyDTO();
    timeDTO = new DailyWorkingActualResultDTO();
    projectInfoDTOList = new ArrayList<ProjectInfoDTO>();
    attendanceSettingList = null;
    timeSettingList = null;
    stampActualResultDTO = new StampActualResultDTO();
    restTimeInfoDTOList = null;
    substituteHoliday = null;
    overTimeWorkingPerMonth = null;
    workingTimeId = null;
    totalOperationTime = null;
    leaveTime = null;
    workingTimeCheckExclusionFlag = false;
    findRestDetailFlag = false;
    announcement = null;
    saveSuccess = false;
    deleteSuccess = false;
    confirmSuccess = false;
    dateChangeFlag = false;
  }

  /**
   * Instantiates a new input daily attendance form.
   */
  public InputDailyAttendanceForm() {
    super();
  }

  /**
   * Gets the user id.
   * 
   * @return the user id
   */
  public String getUserId() {
    return userId;
  }

  /**
   * Sets the user id.
   * 
   * @param userId the new user id
   */
  public void setUserId(String userId) {
    this.userId = userId;
  }

  /**
   * Gets the inits the dto.
   * 
   * @return the inits the dto
   */
  public EmployeeCompanyDTO getInitDTO() {
    return initDTO;
  }

  /**
   * Sets the inits the dto.
   * 
   * @param initDTO the new inits the dto
   */
  public void setInitDTO(EmployeeCompanyDTO initDTO) {
    this.initDTO = initDTO;
  }

  /**
   * Gets the time dto.
   * 
   * @return the time dto
   */
  public DailyWorkingActualResultDTO getTimeDTO() {
    return timeDTO;
  }

  /**
   * Sets the time dto.
   * 
   * @param timeDTO the new time dto
   */
  public void setTimeDTO(DailyWorkingActualResultDTO timeDTO) {
    this.timeDTO = timeDTO;
  }

  /**
   * Sets the project info dto list obj.
   * 
   * @param index the index
   * @param projectInfoDTOListObj the project info dto list obj
   */
  public void setProjectInfoDTOListObj(int index, ProjectInfoDTO projectInfoDTOListObj) {
    projectInfoDTOList.set(index, projectInfoDTOListObj);
  }

  /**
   * Gets the project info dto list obj.
   * 
   * @param i the i
   * @return the project info dto list obj
   */
  public ProjectInfoDTO getProjectInfoDTOListObj(int i) {
    int listObjSize = projectInfoDTOList.size();
    // check if object exists at specified index
    if ((i + 1) > listObjSize) {
      // add objects
      for (int j = listObjSize; j < i + 1; j++) {
        ProjectInfoDTO beanObj = new ProjectInfoDTO();
        projectInfoDTOList.add(j, beanObj);
      }
    }
    // get and return object at this index
    return (ProjectInfoDTO) projectInfoDTOList.get(i);
  }

  /**
   * Gets the project info dto list.
   * 
   * @return the project info dto list
   */
  public List<ProjectInfoDTO> getProjectInfoDTOList() {
    return projectInfoDTOList;
  }

  /**
   * Sets the project info dto list.
   * 
   * @param projectInfoDTOList the new project info dto list
   */
  public void setProjectInfoDTOList(List<ProjectInfoDTO> projectInfoDTOList) {
    this.projectInfoDTOList = projectInfoDTOList;
  }

  /**
   * Gets the stamp actual result dto.
   * 
   * @return the stamp actual result dto
   */
  public StampActualResultDTO getStampActualResultDTO() {
    return stampActualResultDTO;
  }

  /**
   * Sets the stamp actual result dto.
   * 
   * @param stampActualResultDTO the new stamp actual result dto
   */
  public void setStampActualResultDTO(StampActualResultDTO stampActualResultDTO) {
    this.stampActualResultDTO = stampActualResultDTO;
  }

  /**
   * Gets the day.
   * 
   * @return the day
   */
  public String getDay() {
    return day;
  }

  /**
   * Sets the day.
   * 
   * @param day the new day
   */
  public void setDay(String day) {
    this.day = day;
  }

  /**
   * Gets the month.
   * 
   * @return the month
   */
  public String getMonth() {
    return month;
  }

  /**
   * Sets the month.
   * 
   * @param month the new month
   */
  public void setMonth(String month) {
    this.month = month;
  }

  /**
   * Gets the year.
   * 
   * @return the year
   */
  public String getYear() {
    return year;
  }

  /**
   * Sets the year.
   * 
   * @param year the new year
   */
  public void setYear(String year) {
    this.year = year;
  }

  /**
   * Gets the day of week.
   * 
   * @return the day of week
   */
  public String getDayOfWeek() {
    return dayOfWeek;
  }

  /**
   * Sets the day of week.
   * 
   * @param dayOfWeek the new day of week
   */
  public void setDayOfWeek(String dayOfWeek) {
    this.dayOfWeek = dayOfWeek;
  }

  /**
   * Gets the working time id.
   * 
   * @return the working time id
   */
  public String getWorkingTimeId() {
    return workingTimeId;
  }

  /**
   * Sets the working time id.
   * 
   * @param workingTimeId the new working time id
   */
  public void setWorkingTimeId(String workingTimeId) {
    this.workingTimeId = workingTimeId;
  }

  /**
   * Gets the attendance setting list.
   * 
   * @return the attendance setting list
   */
  public List<LabelValueBean> getAttendanceSettingList() {
    return attendanceSettingList;
  }

  /**
   * Sets the attendance setting list.
   * 
   * @param attendanceSettingList the new attendance setting list
   */
  public void setAttendanceSettingList(List<LabelValueBean> attendanceSettingList) {
    this.attendanceSettingList = attendanceSettingList;
  }

  /**
   * Gets the time setting list.
   * 
   * @return the time setting list
   */
  public List<LabelValueBean> getTimeSettingList() {
    return timeSettingList;
  }

  /**
   * Sets the time setting list.
   * 
   * @param timeSettingList the new time setting list
   */
  public void setTimeSettingList(List<LabelValueBean> timeSettingList) {
    this.timeSettingList = timeSettingList;
  }

  /**
   * Gets the substitute holiday.
   * 
   * @return the substitute holiday
   */
  public String getSubstituteHoliday() {
    return substituteHoliday;
  }

  /**
   * Sets the substitute holiday.
   * 
   * @param substituteHoliday the new substitute holiday
   */
  public void setSubstituteHoliday(String substituteHoliday) {
    this.substituteHoliday = substituteHoliday;
  }

  /**
   * Gets the over time working per month.
   * 
   * @return the over time working per month
   */
  public String getOverTimeWorkingPerMonth() {
    return overTimeWorkingPerMonth;
  }

  /**
   * Sets the over time working per month.
   * 
   * @param overTimeWorkingPerMonth the new over time working per month
   */
  public void setOverTimeWorkingPerMonth(String overTimeWorkingPerMonth) {
    this.overTimeWorkingPerMonth = overTimeWorkingPerMonth;
  }

  /**
   * Gets the rest time info dto list.
   * 
   * @return the rest time info dto list
   */
  public List<RestTimeDTO> getRestTimeInfoDTOList() {
    return restTimeInfoDTOList;
  }

  /**
   * Sets the rest time info dto list.
   * 
   * @param restTimeInfoDTOList the new rest time info dto list
   */
  public void setRestTimeInfoDTOList(List<RestTimeDTO> restTimeInfoDTOList) {
    this.restTimeInfoDTOList = restTimeInfoDTOList;
  }

  /**
   * Gets the total operation time.
   * 
   * @return the total operation time
   */
  public String getTotalOperationTime() {
    return totalOperationTime;
  }

  /**
   * Sets the total operation time.
   * 
   * @param totalOperationTime the new total operation time
   */
  public void setTotalOperationTime(String totalOperationTime) {
    this.totalOperationTime = totalOperationTime;
  }
  
  public String getLeaveTime() {
    return leaveTime;
  }

  public void setLeaveTime(String leaveTime) {
    this.leaveTime = leaveTime;
  }

  /**
   * Gets the checks if is editable.
   * 
   * @return the checks if is editable
   */
  public boolean getIsEditable() {
    return isEditable;
  }

  /**
   * Sets the checks if is editable.
   * 
   * @param isEditable the new checks if is editable
   */
  public void setIsEditable(boolean isEditable) {
    this.isEditable = isEditable;
  }

  /**
   * Checks if is working time check exclusion flag.
   * 
   * @return true, if is working time check exclusion flag
   */
  public boolean isWorkingTimeCheckExclusionFlag() {
    return workingTimeCheckExclusionFlag;
  }

  /**
   * Sets the working time check exclusion flag.
   * 
   * @param workingTimeCheckExclusionFlag the new working time check exclusion flag
   */
  public void setWorkingTimeCheckExclusionFlag(boolean workingTimeCheckExclusionFlag) {
    this.workingTimeCheckExclusionFlag = workingTimeCheckExclusionFlag;
  }

  /**
   * Checks if is find rest detail flag.
   * 
   * @return true, if is find rest detail flag
   */
  public boolean isFindRestDetailFlag() {
    return findRestDetailFlag;
  }

  /**
   * Sets the find rest detail flag.
   * 
   * @param findRestDetailFlag the new find rest detail flag
   */
  public void setFindRestDetailFlag(boolean findRestDetailFlag) {
    this.findRestDetailFlag = findRestDetailFlag;
  }

  /**
   * Gets the announcement.
   * 
   * @return the announcement
   */
  public String getAnnouncement() {
    return announcement;
  }

  /**
   * Sets the announcement.
   * 
   * @param announcement the new announcement
   */
  public void setAnnouncement(String announcement) {
    this.announcement = announcement;
  }

  /**
   * Checks if is save success.
   * 
   * @return true, if is save success
   */
  public boolean isSaveSuccess() {
    return saveSuccess;
  }

  /**
   * Sets the save success.
   * 
   * @param saveSuccess the new save success
   */
  public void setSaveSuccess(boolean saveSuccess) {
    this.saveSuccess = saveSuccess;
  }

  /**
   * Checks if is delete success.
   * 
   * @return true, if is delete success
   */
  public boolean isDeleteSuccess() {
    return deleteSuccess;
  }

  /**
   * Sets the delete success.
   * 
   * @param deleteSuccess the new delete success
   */
  public void setDeleteSuccess(boolean deleteSuccess) {
    this.deleteSuccess = deleteSuccess;
  }

  /**
   * Checks if is confirm success.
   * 
   * @return true, if is confirm success
   */
  public boolean isConfirmSuccess() {
    return confirmSuccess;
  }

  /**
   * Sets the confirm success.
   * 
   * @param confirmSuccess the new confirm success
   */
  public void setConfirmSuccess(boolean confirmSuccess) {
    this.confirmSuccess = confirmSuccess;
  }
  
  public boolean getIsDeleteEnabled() {
    return !StringUtil.isEmpty(timeDTO.getDailyWorkingApprovalStatus());
  }

  public boolean isDateChangeFlag() {
    return dateChangeFlag;
  }

  public void setDateChangeFlag(boolean dateChangeFlag) {
    this.dateChangeFlag = dateChangeFlag;
  }

}
